package com.cy.detectsys.controller.db;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.cy.detectsys.entity.DbFofa;
import com.cy.detectsys.entity.DetectTarget;
import com.cy.detectsys.model.PageDto;
import com.cy.detectsys.model.PageReqModel;
import com.cy.detectsys.service.DbFofaService;
import com.cy.detectsys.service.DetectTargetIpService;
import com.cy.detectsys.service.DetectTargetService;
import com.cy.detectsys.util.R;
import com.github.pagehelper.PageHelper;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;

@RestController
@RequestMapping("db/fofa")
public class DbFofaController {


    @Resource
    private DbFofaService baseService;



    @RequestMapping("add")
    public R add(@RequestBody DbFofa fofa) {
        baseService.save(fofa);
        return R.ok(fofa);
    }
    @RequestMapping("update")
    public R update(@RequestBody DbFofa fofa) {
        baseService.updateById(fofa);
        return R.ok(fofa);
    }

    @RequestMapping("delete")
    public R delete(@RequestBody DbFofa fofa) {
        baseService.removeById(fofa);
        return R.ok(fofa);
    }

    @RequestMapping("list")
    public R list(@RequestBody PageReqModel<DbFofa> form) {
        PageHelper.startPage(form.getPage(), form.getPageSize());

        DbFofa model = form.getModel();
        QueryWrapper<DbFofa> detectTargetQueryWrapper = new QueryWrapper<>();

        List<DbFofa> list = baseService.list(detectTargetQueryWrapper);

        return R.ok(PageDto.listToPageDto(list));
    }
}
